#include "omp.h"
#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<int> arr;
    omp_set_num_threads(40);
#pragma omp parallel for ordered
    for (int i = 0; i < 40; i++) {
        int id = omp_get_thread_num();
        printf("%d \n", id);
        /*
         * order之后全部按照顺序执行
         */
#pragma omp ordered
        printf("this is a lock %d\n", id);
        arr.push_back(id);
    }
    int size = arr.size();
    for (int i = 0; i < size; i++) {
        printf("%d ", arr[i]);
    }
    printf("\n");
    return 0;
}